/**
 *  DataHandler.h
 *  farfetchproject
 *
 *  Created by Rodrigo Souza on 4/18/10.
 *  Copyright 2010 Unicamp. All rights reserved.
 */
 
#ifndef _DATA_HANDLER_H
#define _DATA_HANDLER_H

#define LINE_SIZE 		200
#define DATABASE_NAME 	"database.dat"

#define MOVIE_NOT_FOUND "*** Filme não encontrado ***"
#define OPT_ERROR "*** Opção não implementada!!! ***"

typedef struct Movie {
	int 	id;
	char* 	title;
	char* 	sinopse;
	char* 	room;
	char* 	hours;
	float 	rate;
	int 	clients;
	int 	valid;
} Movie;

typedef Movie* MoviesList;

typedef struct Request {
	int option;
	int value;
	int rate;
} Request;


/**
 * Find the file wich contains database informations.
 * @param 	fileName a string name for the file
 * @return 	FILE* file fileName.dat
 */
FILE* findDataSource(char* fileName);


/**
 * Get movies from database.
 * @param 	fp a string name for the file
 * @return 	MoviesList
 */
MoviesList getMovies(FILE* fp);


/**
 * Initialize the data handler.
 */
void initDataHandler();


/**
 * Get id and title of all movies.
 *
 * @return 	char* with data to send to client
 */
char* getNumberMoviesList();


/**
 * Get all info about the movies.
 * 
 * @return 	char* with data to send to client
 */
char* getAllInfoMoviesList();


/**
 * Get id and title of all movies.
 * @param 	int id movie
 * @return 	char* with data to send to client
 */
char* getSinopseMovie(int id);


/**
 * Get id and title of all movies.
 * @param 	int id movie
 * @return 	char* with data to send to client
 */
char* getAllInfoMovie(int id);


/**
 * Get id and title of all movies.
 * @param 	int id movie
 * @return 	char* with data to send to client
 */
char* getMediumMovie(int id);


/**
 * Set the rate of movie.
 * @param 	Request request option from client
 * @return 	char* with data to send to client
 */
char* setRateMovie(Request req);


#endif
